package com.dylan.shot.common.service.impl;

import com.dylan.shot.common.model.City;
import com.dylan.shot.common.service.CityService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * Created by Dylan on 2017/9/4.
 */
@Service("cityService")
public class CityServiceImpl extends BaseService<City> implements CityService {
    @Override
    public List<City> getByCitySimpleNameLike(String citySimpleName) {
        citySimpleName = StringUtils.defaultString(citySimpleName).trim();
        Example example = new Example(City.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andLike("citySimpleName", "%" + citySimpleName + "%");
        return selectByExample(example);
    }

    @Override
    public int getCountByCitySimpleNameLike(String citySimpleName) {
        citySimpleName = StringUtils.defaultString(citySimpleName).trim();
        Example example = new Example(City.class);
        example.createCriteria().andLike("citySimpleName", "%" + citySimpleName + "%");
        return selectCountByExample(example);
    }
}
